package com.koko.controller;

import com.koko.game.entity.GameRequire;
import com.koko.result.Result;
import com.koko.service.GameRequireService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/game")
public class GameRequireController {
    @Autowired
    private GameRequireService gameRequireService;

    @PutMapping("/admin/require")
    @CacheEvict(value = "gameCache", allEntries = true)
    public Result<String> updateGameRequire(@RequestBody GameRequire gameRequire) {
        gameRequireService.update(gameRequire);
        return Result.success();
    }

    @PostMapping("/admin/require")
    @CacheEvict(value = "gameCache", allEntries = true)
    public Result<String> addGameRequire(@RequestBody GameRequire[] gameRequires) {
        gameRequireService.add(gameRequires);
        return Result.success();
    }
}
